Technical Q&ATB 06 - Creating a Menu with an Icon as its Title (1-May-95)Q How do I create a menu with an icon as its title, such as AppleScript(TM) and other products use? A The menu data for the menu title must be 0x0501<handle> where <handle> is replaced by the the results of calling GetIconSuite(). An example snippet of code follows. This snippet assumes that the menu title is already 5 bytes long. void ChangeToIconMenu() { Handle theIconSuite = nil; MenuHandle menuHandle; GetIconSuite(&theIconSuite, cIcon, svAllSmallData); if (theIconSuite) { menuHandle = GetMenuHandle(mIcon); if (menuHandle) { // second byte must be a 1, followed by the icon suite handle (**menuHandle).menuData[1] = 0x01; *((long *)&((**menuHandle).menuData[2])) = (long)theIconSuite; // update display (typically you do this on startup) DeleteMenu(mIcon); InsertMenu(menuHandle, 0); InvalMenuBar(); } } } Technical Q&A Previous Question | Contents | Next Question |